﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminCP/Layouts/Admin.Master" AutoEventWireup="true" CodeBehind="Contact.aspx.cs" Inherits="Thuoc24h.AdminCP.Pages.Contact" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphContent" runat="server">
    <Telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">

            function RowDblClick(sender, eventArgs) {
                window.radopen("/AdminCP/Pages/ViewContact.aspx?ID=" + eventArgs.getDataKeyValue("Id"), "UserListDialog");
            }

            function pageOnload(sender, eventArgs) {
             //   var masterTable = $find("<%=gridData.ClientID%>").get_masterTableView();
             //   masterTable.rebind();
                window.location.reload();
            }
        </script>
    </Telerik:RadCodeBlock>
    <Telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <Telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <Telerik:AjaxUpdatedControl ControlID="gridData" LoadingPanelID="gridLoadingPanel"></Telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </Telerik:AjaxSetting>
            <Telerik:AjaxSetting AjaxControlID="gridData">
                <UpdatedControls>
                    <Telerik:AjaxUpdatedControl ControlID="gridData" LoadingPanelID="gridLoadingPanel"></Telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </Telerik:AjaxSetting>
        </AjaxSettings>
    </Telerik:RadAjaxManager>
    <Telerik:RadAjaxLoadingPanel runat="server" ID="gridLoadingPanel" ></Telerik:RadAjaxLoadingPanel>
    <Telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true">
        <Windows>
            <Telerik:RadWindow ID="UserListDialog" runat="server" Title="Chi tiết liên hệ" Height="600px" OnClientClose="pageOnload"
                Width="800px" Left="150px" ReloadOnShow="True" ShowContentDuringLoad="false" 
                Modal="true">
            </Telerik:RadWindow>
        </Windows>
    </Telerik:RadWindowManager>
    
       <div class="item">
                    <label>Lọc tin:</label><Telerik:RadComboBox runat="server" ID="cbbFillter" Width="350px"  EmptyMessage="Lọc tin nhắn" AutoPostBack="True">

                        <Items>
                            <Telerik:RadComboBoxItem runat="server" Text="Xem tất cả" Value="" />
                            <Telerik:RadComboBoxItem runat="server" Text="Chưa đọc" Value="False" />
                            <Telerik:RadComboBoxItem runat="server" Text="Đã đọc" Value="True" />
                        </Items>
                        <CollapseAnimation Duration="200" Type="OutQuint" />
                    </Telerik:RadComboBox>

                </div>

    <Telerik:RadGrid runat="server" AutoGenerateColumns="False" ID="gridData" CellSpacing="0" GridLines="None" DataSourceID="ContactEds" Width="100%"
        AllowPaging="True" AllowCustomPaging="True" OnItemCommand="gridData_ItemCommand" AllowSorting="True">
        <MasterTableView ClientDataKeyNames="Id" DataKeyNames="Id" GroupLoadMode="Client"
            PageSize="20" NoMasterRecordsText="Không có bản ghi nào.">
            <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
            <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>

            <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
            <GroupByExpressions>
            </GroupByExpressions>
            <Columns>
                <Telerik:GridTemplateColumn HeaderText="STT" UniqueName="Id">
                    <ItemStyle HorizontalAlign="Left" CssClass="center" />
                    <ItemTemplate>
                        <%#
                   (gridData.PageSize * (gridData.CurrentPageIndex + 1)) - gridData.PageSize + Container.ItemIndex + 1
                        %>
                    </ItemTemplate>
                    <HeaderStyle Font-Bold="True" HorizontalAlign="Center" Width="50px" />
                </Telerik:GridTemplateColumn>
                <Telerik:GridTemplateColumn HeaderText="Name" UniqueName="Title">
                    <ItemTemplate>
                        <%# (bool)Eval("IsRead")?Eval("Name"): "<b>"+Eval("Name")+"<b>" %>
                    </ItemTemplate>
                    <HeaderStyle Font-Bold="True" HorizontalAlign="Center" />
                    <ItemStyle HorizontalAlign="Left" />
                </Telerik:GridTemplateColumn>

                <Telerik:GridTemplateColumn HeaderText="Điện thoại" UniqueName="PhoneNumber">
                    <ItemTemplate>
                        <%# Eval("PhoneNumber")  %>
                    </ItemTemplate>
                    <HeaderStyle Font-Bold="True" HorizontalAlign="Center" />
                    <ItemStyle HorizontalAlign="Center" Width="200" />
                </Telerik:GridTemplateColumn>
                <Telerik:GridTemplateColumn HeaderText="Email" UniqueName="Email">
                    <ItemTemplate>
                        <%# Eval("Email")  %>
                    </ItemTemplate>
                    <HeaderStyle Font-Bold="True" HorizontalAlign="Center" />
                    <ItemStyle HorizontalAlign="Center" Width="60" />
                </Telerik:GridTemplateColumn>
                <Telerik:GridTemplateColumn HeaderText="Ngày tạo" UniqueName="CreatedDate">
                    <ItemTemplate>
                        <%# Eval("CreatedDate") %>
                    </ItemTemplate>
                    <HeaderStyle Font-Bold="True" HorizontalAlign="Center" />
                    <ItemStyle HorizontalAlign="Left" Width="150" />
                </Telerik:GridTemplateColumn>
                <Telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" ConfirmDialogType="RadWindow"
                    ConfirmText="Bạn có chắc chắn muốn xóa" ConfirmTitle="Xóa" HeaderText="X&#243;a"
                    Text="X&#243;a" UniqueName="Delete">
                    <ItemStyle CssClass="center" Width="32px" />
                    <HeaderStyle HorizontalAlign="Center" Width="32px" Font-Bold="True" />
                </Telerik:GridButtonColumn>
            </Columns>
            <EditFormSettings EditFormType="Template">
                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                </EditColumn>
            </EditFormSettings>
        </MasterTableView>
        <ClientSettings EnableRowHoverStyle="True">
            <Selecting AllowRowSelect="true"></Selecting>
            <ClientEvents OnRowDblClick="RowDblClick"></ClientEvents>
        </ClientSettings>
        <FilterMenu EnableImageSprites="False"></FilterMenu>

        <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>


    </Telerik:RadGrid>

    <asp:EntityDataSource runat="server" ID="ContactEds" ConnectionString="name=MedLifeDataContext" DefaultContainerName="MedLifeDataContext" EnableFlattening="False" EntitySetName="Contacts" Select="it.[Id], it.[Name], it.[Email], it.[PhoneNumber], it.[CreatedDate],it.[IsRead]" AutoGenerateWhereClause="True" OrderBy="it.[Id] DESC" Where="" EntityTypeFilter="">
        <OrderByParameters>
            <asp:Parameter Name="Id" DefaultValue="" Type="Int32" />
        </OrderByParameters>
        <WhereParameters>
            <asp:ControlParameter ControlID="cbbFillter" Name="IsRead" PropertyName="SelectedValue" DbType="Boolean" />
            <asp:Parameter DefaultValue="1" Name="TypeRequest" Type="Int32" />
        </WhereParameters>
    </asp:EntityDataSource>


</asp:Content>
